COM_SendPacket
Sends a communication protocol packet (byte-array) via a USB or Bluetooth channel (serial port)
Contents
Syntax
COM_SendPacket(Packet, handle)
Description
COM_SendPacket(Packet, handle) sends the given byte-array Packet (column vector), (which can easily be created by the function COM_CreatePacket) over the USB or Bluetooth channel specified by the given handle (struct) created by the function COM_OpenNXT or COM_OpenNXTEx, or obtained from COM_GetDefaultNXT.
Note:
In the case of a Bluetooth connection this function uses the specific settings from the ini-file that was specified when opening the handle. Parameters used here are SendSendPause and SendReceivePause, which will cause this function to wait a certain amount of milliseconds between each consecutive send or receive operation to avoid packet loss or buffer overflows inside the blutooth stack.
Example
COM_MakeBTConfigFile(); handle = COM_OpenNXT('bluetooth.ini', 'check'); [type cmd] = name2commandbytes('KEEPALIVE'); content = []; % no payload in NXT command KEEPALIVE packet = COM_CreatePacket(type, cmd, 'dontreply', content); COM_SendPacket(packet, bt_handle);
See also
COM_CreatePacket, COM_CollectPacket, COM_OpenNXT, COM_GetDefaultNXT, COM_MakeBTConfigFile
Signature
- Author: Linus Atorf (see AUTHORS)
- Date: 2008/07/09
- Copyright: 2007-2008, RWTH Aachen University